import run_route from '../kernel/route/pars_route'
import controRoute from '../kernel/route/controRoute';
import Middleware from '../kernel/middleware/middleware';

if(module) module.exports = any;
//any请求的接口
export default async function any (ctx:any,url:string){
    if(!controRoute.getUnStaticRoute(ctx.module.filename) || global.gem_Route?.ID!==ctx.module.filename){
        console.log("请先使用@"+"Controller注解后使用@"+"GetMapping",ctx.module.filename);
        return
    }

    //调用路由
    global.controller[ctx.module.filename][ctx.methodName] = 
    global.gem_Route.any(url,Middleware.createMiddleware(
        ctx.module.filename,ctx.module.exports.default || ctx.module.exports,ctx.methodName,[]
    ));

    if(ctx.isEnd){
        //合并一下路由
        await run_route.mergeRout();
        global.gem_Route = undefined
    }
}